<?php

namespace Wanecho\FlarumApp\Controllers;

use Psr\Http\Server\RequestHandlerInterface;
use Laminas\Diactoros\Response\HtmlResponse;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

use Composer\IO\ConsoleIO;
use Composer\Installer;
use Composer\Repository\ArrayRepository;
use Composer\Package\Package;
use Composer\Config;

class AppController implements RequestHandlerInterface
{
    public function handle(Request $request): Response
    {
        // $packageName = 'wanecho/hello';
        // $command = 'composer require ' . $packageName;
        // passthru($command, $return_var);
        // $composerJson = json_decode(file_get_contents('composer.json'), true);
        // if ($return_var === 0 && !empty($composerJson['require'][$packageName])) {
        //     //检测是否安装成功
        //     $msg =  "Composer command successful";
        // } else {
        //     $msg =   "Composer command failed";
        // }
        return new  HtmlResponse('');
    }
}
